package cn.com.zero.api.auth.vo;

import cn.com.zero.base.constant.DateFormatPatternConstants;
import cn.com.zero.base.vo.BaseVO;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Date;
import java.util.Objects;

/**
 * @author xiongxj
 * @version 1.0.0
 * @Description 被锁定用户信息
 * @createTime 2023/3/28 14:06
 */
public class LockedUserVO extends BaseVO implements Cloneable {

    private static final long serialVersionUID = -7394361515111355602L;
    /**
     * 被锁定的用户ID
     */
    private String userId;

    /**
     * 被锁定时间
     */
    @JsonFormat(pattern = DateFormatPatternConstants.DATE_TIME_MIDDLE_BAR)
    private Date lockedTime;

    /**
     * 登录IP
     */
    private String loginIp;

    /**
     * 登录时间
     */
    @JsonFormat(pattern = DateFormatPatternConstants.DATE_TIME_MIDDLE_BAR)
    private Date loginTime;

    /**
     * 克隆锁定用户信息
     * 注意：继承此类的子类，需要重写此方法，否则子类中的属性等无法克隆
     *
     * @param onlineUserVO 需要克隆的信息
     * @return 克隆后的用户信息
     */
    public LockedUserVO clone(LockedUserVO onlineUserVO) {
        LockedUserVO lockedUser = null;
        try {
            lockedUser = (LockedUserVO) super.clone();
        } catch (CloneNotSupportedException e) {
        }
        return lockedUser;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        LockedUserVO that = (LockedUserVO) o;
        return userId.equals(that.userId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId);
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public Date getLockedTime() {
        return lockedTime;
    }

    public void setLockedTime(Date lockedTime) {
        this.lockedTime = lockedTime;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Date getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(Date loginTime) {
        this.loginTime = loginTime;
    }
}
